
const {Sequelize} = require('sequelize')


//
// const sequelize = new Sequelize('test', 'root', 'root', {
//     host: 'localhost',
//     dialect: 'mysql'
// });



// 数据库配置
const config = {
    host: "rm-wz99742lbk264pxq3o.mysql.rds.aliyuncs.com",
    username: "lingmeiyunhe",
    password: "LINGmeiYunHE1212Super",
    database: "gzttyy",
    dialect: "mysql",
    // 连字符
    schemaDelimiter: '_',
    timezone: '+08:00',  // 对于东八区，这是必须的设置
    pool: {
        idle: 5000,
    },
    define: {
        timestamps: false, // 防止 sequelize 自动生成 createdAt 和 updatedAt 字段
    },
};

// 连接数据库
const db = new Sequelize(config);
// try {
//     //db.authenticate().then(r => );
//     console.log("成功连接到数据库");
// } catch (error) {
//     console.error("无法连接到数据库:", error);
// }

try {
     db.authenticate();
    console.log('Connection has been established successfully.');
} catch (error) {
    console.error('Unable to connect to the database:', error);
}

module.exports = db;


